﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ExaminationSys.DataAccess.Repository;
using ExaminationSys.DataAccess;
using ExaminationSys.DataAccess.Entity;

namespace ExaminationSys.View.Student
{
    public partial class JoinExaminationSubject : System.Web.UI.Page
    {
        public string subjectcontent = string.Empty;
        public string sourceurl = string.Empty;
        private static readonly DBSubjectService Proxy = ObjectFactory<DBSubjectService>.Create();

        protected void Page_Load(object sender, EventArgs e)
        {
            if (Page.Request.QueryString["subjuecttempid"] != null)
            {
                string id = Page.Request.QueryString["subjuecttempid"];
                DBSubject dBSubject = Proxy.Get(new Guid(id));
                if (dBSubject != null)
                {
                    var host = GetHost();
                    subjectcontent = dBSubject.Content;
                    sourceurl = String.Format("{0}/UpLoadFiles/DBSubject/{1}", host, dBSubject.AttachFile);
                }
            }
        }
        private string GetHost()
        {
            var host = "http://" + HttpContext.Current.Request.Url.Host;
            var portflag = HttpContext.Current.Request.Url.IsDefaultPort;
            host += portflag ? "" : (":" + HttpContext.Current.Request.Url.Port);

            return host;
        }
    }
}